export default {
    state: () => ({
        //  底部元素
        element: null,
        // 定时器
        setTime: null,
        // 底部显示与隐藏时的动画class
        bottom: null,
        //  1.5秒后隐藏底部
        hideenTime: function (state, flag) {
            if (flag) {
                clearTimeout(state.setTime);
                state.setTime = setTimeout(() => {
                    state.bottom = "shut-down";
                }, 1500);

            }
        }
    }),
    mutations: {
        //  显示底部
        showEnter: (state, flag = false) => {
            if (state.element.offsetTop === 0) {
                //  显示时的动画样式class
                state.bottom = "open";
                state.hideenTime(state, flag);

            } else {
                //  清除隐藏底部定时器功能
                clearTimeout(state.setTime);
                state.hideenTime(state, flag);
            }
        },
        //  隐藏底部
        showLeave: (state, value = 500) => {
            state.setTime = setTimeout(() => {
                //  隐藏时的动画样式class
                state.bottom = "shut-down";
            }, value);
        },
        //  获取底部元素
        getElement: (state, value) => {
            state.element = value;
        },

    }
}